package com.xiegang.apipassenger.controller;

import com.xiegang.apipassenger.Service.VerificationCodeService;
import com.xiegang.internalcommon.dto.ResponseResult;
import com.xiegang.internalcommon.request.VerificationCodeDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xieGang
 * @description
 * @date 2023/2/28 19:46
 **/
@RestController
public class VerificationCodeController {

    @Autowired
    private VerificationCodeService verificationCodeService;

    @GetMapping("/verificationCode")
    public ResponseResult verificationCode(@RequestBody VerificationCodeDto verificationCodeDto){

        String passengerPhone = verificationCodeDto.getPassengerPhone();
        return verificationCodeService.verificationCode(passengerPhone);
    }

    @PostMapping("/verificationCodeCheck")
    public ResponseResult checkVerificationCode(@RequestBody VerificationCodeDto verificationCodeDto){

        String passengerPhone = verificationCodeDto.getPassengerPhone();
        String verificationCode = verificationCodeDto.getVerificationCode();

        System.out.println("乘客手机号："+passengerPhone+"，验证码："+verificationCode);

        return verificationCodeService.checkVerificationCode(passengerPhone,verificationCode);
    }
}
